<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Product list template
 *
 * @see Mage_Catalog_Block_Product_List
 */
?>
<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');
?>

    
<div class="col-main">
    <?php
        $category = Mage::registry('current_category');
        $category_id = $category->getId();
        
        if(!empty($category_id)){
            $model = Mage::getModel("catalog/category")->load($category_id);
            $pdfName = $model->getPdfName();
           
        }
    ?>
    <?php if(!empty($pdfName)): ?>
        <a target="_blank" href="<?php echo $this->getUrl("home/index/exportPdfCatalog/category_id/$category_id") ?>" class="view-pdf"><?php echo $category->getMetaTitle() ?></a>
    <?php endif; ?>
    <?php if(!$_productCollection->count()): ?>
    <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
    <?php else: ?>
        <?php echo $this->getToolbarHtml() ?>
            <?php // List mode ?>
            <?php $_iterator = 0; ?>
        <div class="product">
            <ul class="list-product clearfix">
                <?php foreach ($_productCollection as $_product): ?>
                <li>
                    <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
                    <div class="product-summary">
                        <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(PRODUCTLIST_WIDTH,PRODUCTLIST_HEIGHT); ?>"   alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>

                        <div class="product-info">
                            <p class="name"><strong><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></strong></p>

                            <p><strong><?php echo $this->__("NBS Part") ?>#: </strong> <?php echo $_product->getSku() ?> </p>
                            <p><strong><?php echo $this->__("Model") ?>#:</strong> <?php echo $_product->getModelNumber() ?> </p>
                            <?php /*
							<?php $categoryIds  =$_product->getCategoryIds();  ?>
                            <?php if(!empty($categoryIds)): ?>
                                <p><?php echo $this->__("Catalog Pg #:") ?> <?php echo $categoryIds[0] ?></p>
                            <?php endif;?>
                            */?>
                        </div>
                    </div>
                    <div class="add-cart">
                        <p>
                            <?php echo $this->__("Our price"); ?>:
                            <?php echo $formattedPrice = Mage::helper('core')->currency($_product->getFinalPrice(),true,false); ?>
                        </p>

                        <?php //echo $this->getPriceHtml($_product, false) ?>
                        <p><?php  echo $this->__("Quantity") ?> <input type="text" value="1" name="qty" id="qty<?php echo $_product->getId() ?>"/></p>
                        <?php if($_product->isSaleable()): ?>
                                <p><a class="add-to-cart" title="<?php echo $this->__('Add to Order') ?>"
                                      onclick="addToCart('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId() ?>')">
                                              <?php echo $this->__("Add to order") ?>
                                    </a>
                                </p>
                        <?php else: ?>
                                <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                        <?php endif; ?>

                    </div>
                </li>
                <?php endforeach; ?>
            </ul>
        </div>
</div>
<?php endif;?>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<script type="text/javascript">
    
    function addToCart(link_add,product_id){
        
        var qty = jQuery("#qty"+product_id).val();
        link_add = link_add + "qty/" + qty;
        
        window.location = link_add;

    }
</script>